// A scene that is need polymorphism.

#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <cstdio>
using namespace std;


class Thread {
	public:
		void start( ){
			pthread_create( &m_tid, NULL, threadfunc, this );
		}
		static void* threadfunc( void* arg ) {
			Thread* p = (Thread*)arg;
			p->run( );
		}
		virtual void run( ) = 0;
	private:
		pthread_t m_tid;
};

// designer
// ------------------------------------------------------------------
// user

class MyThread : public Thread {
	public:
		void run( ) {
			for( ;; ) {
				usleep( 1000*500 );
				cout << '+' << flush;
			}
		}
};

int main( void ) { 
	MyThread t1, t2;
	t1.start( );
	t2.start( );
	getchar( );

	return 0;
}

